﻿#ifndef TRQUOTEDATA_H
#define TRQUOTEDATA_H

#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QTextCodec>
#include <QObject>
#include <QString>
#include <QDebug>
#include <QDate>
#include <QUrl>
#include "TrChartTypes.h"

#define SINA_M "https://stock2.finance.sina.com.cn/futures/api/jsonp.php/=/InnerFuturesNewService.getFewMinLine?symbol={:1}&type={:2}"
#define SINA_D "https://stock2.finance.sina.com.cn/futures/api/jsonp.php/=/InnerFuturesNewService.getDailyKLine?symbol={:1}&_={:2}"

class TrQuoteData : public QObject
{
    Q_OBJECT
public:
    explicit TrQuoteData(QObject *parent = nullptr);
    void quote(const QString& code, int period = 0);

signals:
    void OnReplay(QJsonArray);
protected:
    QNetworkRequest Request();
    void handleData(QString json);
public slots:
    void Finished();
    void onError(QNetworkReply::NetworkError e);
private:
    QNetworkAccessManager*  m_pManager = nullptr;


};

#endif // TRQUOTEDATA_H
